using System.Collections.Generic;

namespace RewiredConsts.__Naptime
{
	public static class CollectionExtension
	{
		public static T GetNextKey<T, TD>(this Dictionary<T, TD> dictionary, T searchId)
		{
			List<T> list = new List<T>(dictionary.Keys);
			if (!list.Contains(searchId))
			{
				return list[0];
			}
			int num = list.IndexOf(searchId);
			if (num != list.Count - 1)
			{
				return list[num + 1];
			}
			return list[0];
		}

		public static T GetPreviousKey<T, TD>(Dictionary<T, TD> dictionary, T searchId)
		{
			List<T> list = new List<T>(dictionary.Keys);
			if (!list.Contains(searchId))
			{
				return list[list.Count - 1];
			}
			int num = list.IndexOf(searchId);
			if (num != 0)
			{
				return list[num - 1];
			}
			return list[list.Count - 1];
		}
	}
}
